package com.liu.stockmarket.repository.database.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.liu.stockmarket.model.Stock
import java.math.BigDecimal
import java.time.LocalDate
import java.time.LocalDateTime

/**
 * 股票、可转债、基金
 */

@Entity(tableName = "stock")
data class StockEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Long? = null,
    val code: String,
    val name: String,
    @ColumnInfo(name = "stock_type")
    val stockType: Stock.StockType,

    @ColumnInfo(name = "transaction_exchange")
    val transactionExchange: Stock.TransactionExchange,

    /**
     * 持仓价,当数量为0时，为盈亏
     */
    @ColumnInfo(name = "holding_price")
    val holdingPrice: BigDecimal,

    /**
     * 持仓数量
     */
    @ColumnInfo(name = "holding_number")
    val holdingNumber: BigDecimal,


    /**
     * 首次交易时间
     */
    @ColumnInfo(name="first_transaction_date")
    val firstTransactionDate:LocalDate,

    /**
     * 更新时间
     */
    @ColumnInfo(name = "update_datetime")
    val updateDateTime: LocalDateTime? = LocalDateTime.now(),

    /**
     * 添加时间
     */
    @ColumnInfo(name = "create_datetime")
    val createDateTime: LocalDateTime? = LocalDateTime.now(),

    /**
     * 是否是自选
     */
    val self:Boolean = false,
    )